import React from 'react';
import './index.less';
import {connect} from "dva";
import Curd from "components/Curd";
import createColumns from './columns';
import searchColumns from './searchColumns'


@connect(({dataList, channel, hospital}) => ({dataList, channel, hospital}))
export default class extends Curd {

  static defaultProps = {
    align: 'center',
    disabledAdd: true,
  }


  getNamespace() {
    return 'dataList';
  }

  getTableColumns() {
    return createColumns(this);
  }

  getSearchColumns() {
    return searchColumns(this);
  }

  /**
   * 异步获取需要的数据
   * @returns {{dict: *, loading: *}}
   */
  getChannel = () => {
    const {all, loadingAll} = this.getModel('channel');

    const dict = (!!all && all.length > 0) ? all.map(v => {
      return ({code: v.channel, codeName: v.name})
    }) : undefined;

    return ({loading: loadingAll, dict});
  }


}
